package com.zl.learning.db.sqlite.sqlite;

import org.junit.Test;

import javax.sql.DataSource;
import java.sql.Connection;
import java.sql.SQLException;

public class TestDatasource {

    @Test
    public void test1() {
        DataSource dataSource = DataSourceUtil.getDataSource();
        new Thread(()->{
            try {
                Connection conn1 = dataSource.getConnection();
//                conn1.close();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }).start();

        new Thread(()->{
            try {
                Connection conn2 = dataSource.getConnection();
            } catch (SQLException e) {
                e.printStackTrace();
            }
        }).start();

        while (true){}
    }

    @Test
    public void test2() throws SQLException {
        DataSource dataSource = DataSourceUtil.getDataSource();
        Connection conn1 = dataSource.getConnection();
        conn1.close();
    }
}
